class Animal{
    String name = "旺财";
    int age = 10;
    public void eat(){
        System.out.println(name+"正在吃饭~~~");
    }
    public void sleep(){
        System.out.println(name+"正在吃饭~~~");
    }
}
class Dog extends Animal{
    void bark(){
        System.out.println(name+"正在汪汪汪~~~");
    }
}
class Cat extends Animal{
    void mew(){
        System.out.println(name+"正在喵喵喵~~~");
    }
}
class Base{
    public Base(){
        System.out.println("父类构造方法！");
    }
}
class Derived extends Base{
     public Derived(){
         //super();  子类会调用父类中的构造方法，并且必须放在第一条语句（编译器自动生成）
         //只有一个生命周期
        System.out.println("子类中的构造方法！");
    }
}
public class Test {
    public static void main(String[] args) {
        Derived derived = new Derived();
    }
    public static void main1(String[] args) {
        Dog dog = new Dog();
        System.out.println(dog.name);
        System.out.println(dog.age);
        dog.bark();
        dog.eat();
        dog.sleep();
    }
}
